home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4020 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: news.lpr.carel.fi!usenet
  2. From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: 256 colors in BCG
  5. Date: Thu, 01 Feb 1996 11:32:04 +0200
  6. Organization: Carelcomp Forest
  7. Message-ID: <31108894.41F9@cmt.lpr.mail.carel.fi>
  8. References: <4enojq$4j@badger.wmin.ac.uk>
  9. NNTP-Posting-Host: renoir.cclahti.carel.fi
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b6a (WinNT; I)
  14.  
  15. Declan Kruppa wrote:
  16. > I am using a borland compiler and want to write images to the screen
  17. > with 256 grey levels or alternatively 256 graded in a recognisable way
  18. > eg. rainbow. I know that in mode 13h I have acess to 256 colors
  19. > but at a lower resolution then vga. Also accessing mode 13h means
  20. > writing some assembly code. Is there a library on the net which will
  21. > give me 256 grey levels that can be called from a standard c programme.
  22. > thanks
  23. > Declan Kruppa
  24.  
  25. Actually, mode 13h is one of the easiest modes to handle. When you're using it, you'll 
  26. have 320x200 bytes of memory (abt. 64kB) starting at the address 0xa000:0000, which can be 
  27. accessed, for example, by:
  28.  
  29.     /* large memory model, 16-bit program */
  30.     unsigned char far    *ptr = (unsigned char far *)0xa0000000UL;
  31.  
  32.     memset(ptr, 0, 320);    /* Set first row to all black (0 defaults to black) */
  33.  
  34. Ie. you just go and set the byte at the offset [y][x] (ptr + y * 320 + x) to the color 
  35. index you want used (there are two INT 0x10 services to change the default palette 
  36. mapping; see Ralph Brown's interrupt list). There is also a handy INT 0x10 service to set 
  37. the mode to 256 shade gray, but I forgot it; again, check out Ralph Brown's interrupt 
  38. list. You may also find the book 'Programming the PC & PS/2 Video Systems' (by Wilson?) 
  39. from Microsoft Press worth looking at. It discusses other modes and video cards, too.
  40.  
  41. Later,
  42.  AriL
  43. -- 
  44. All my opinions are mine and mine alone.
  45.